package com.onlineMIS.ORM.DAO.headQ.inventory;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Repository;
import com.onlineMIS.ORM.DAO.BaseDAO;
import com.onlineMIS.ORM.entity.headQ.inventory.HeadqInventoryFlowOrderProduct;


@Repository
public class HeadQInventoryFlowOrderProductDAOImpl extends BaseDAO<HeadqInventoryFlowOrderProduct> {
	
	
	@SuppressWarnings("unchecked")
	public void deleteProducts(final List<String> ids) {
		
		if (ids != null && ids.size() > 0){
			
			String parameter = "(order_id =" + "?" + "and product_id =" + "?" + ")";
			for (int i =1;i<ids.size();i++) {
				parameter +="or (order_id =" + "?"+"and product_id =" + "?" + ")";
			}
			
			final String hql = "delete from HeadqInventoryFlowOrderProduct  where " + parameter;
			
			Object[] values = new Object[ids.size()];
			List<Object> list =  new ArrayList<Object>();
			
			for (int i = 0; i < ids.size(); i++){
//				values[i] = ids.get(i);

				String[] stringArray = ids.get(i).split("@");
				list.add(stringArray[0]);
				list.add(stringArray[1]);

			}
			executeHQLUpdateDelete(hql, list.toArray(), true);
			
		}
	}


}
